package shiyan3;
import java.util.HashMap;
import java.util.Map;

public class MapExercise {
    public static void main(String[] args) {
        // 创建HashMap存储学生成绩
        Map<String, Integer> studentScores = new HashMap<>();
        studentScores.put("张三", 85);
        studentScores.put("李四", 90);
        studentScores.put("王五", 78);
        
        // 查找特定学生并更新成绩
        String targetStudent = "李四";
        if (studentScores.containsKey(targetStudent)) {
            int oldScore = studentScores.get(targetStudent);
            int newScore = oldScore + 10;
            studentScores.put(targetStudent, newScore);
            System.out.println(targetStudent + "的成绩已从 " + oldScore + " 更新为 " + newScore);
        } else {
            System.out.println("未找到学生: " + targetStudent);
        }
        
        // 打印更新后的Map
        System.out.println("\n更新后的学生成绩:");
        for (Map.Entry<String, Integer> entry : studentScores.entrySet()) {
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }
    }
}
//功能：管理学生成绩表，查找特定学生并将其成绩提高10分。
